home *** CD-ROM | disk | FTP | other *** search
- /*
- dshell v3
-
- 6万色グラフィック表示モード関係 (オリジナル by BEEPs)
- */
-
- #include "dsh.h"
-
-
- /* gsub.s */
- void set_ibit(void);
-
-
- void
- g_mask(int x, int y, char *mask)
- {
- struct TREVPTR buf;
- char *pos;
-
- buf.vram_page = 1;
- buf.x = x * 8;
- buf.y = y * 16;
- buf.x1 = 8;
- buf.y1 = 16;
-
- for (pos = mask; *pos; pos++) {
- if (*pos == '_') {
- TXREV(&buf);
- }
- buf.x += 8;
- }
- return;
- }
-
-
- void
- g_push(int initFlag)
- {
- ushort r20;
-
- vsync();
- if (GMODE == 1) {
- CRTMOD(12 + 0x100);
- } else {
- if (CRTMOD(-1) != 12
- || (B_WPEEK(VIDEOR0) & 0x0003) != 0x0003
- || (r20 = B_WPEEK(CRTCR20)) != 0x0315 && r20 != 0x316)
- CRTMOD(12 + 0x100);
- to_square();
- }
- setWidth();
- #if 1
- B_LPOKE((unsigned long *)0x95c, 0x00c00000);
- B_LPOKE((unsigned long *)0x960, 0x00000400);
- B_LPOKE((unsigned long *)0x964, 0xffffffff);
- B_LPOKE((unsigned long *)0x968, 0x00000000);
- B_LPOKE((unsigned long *)0x96c, 0x01ff01ff);
- #endif
-
- vsync();
- set_ibit(); /* パレットの操作と輝度ビットオン(g_sub.s) */
- noSetIbitFlag = TRUE;
-
- vsync();
- B_WPOKE(VIDEOR1, 0x21E4); /* プライオリティ TX > GR > SP */
- B_WPOKE(VIDEOR2, 0x1d2F); /* 半透明 TX & GR */
-
- B_CONSOL(0, 0, 128 - 1, 64 - 1);
- if (initFlag) {
- initPalet();
- Init_Upper_Bar();
- Init_Under_Bar();
- B_COLOR(3);
- }
- }
-
- /*
- グラフィック画面のみ一時オンにする
- */
- void
- g_pop()
- {
- int x, y, r, l;
-
- vsync();
- B_WPOKE(VIDEOR2, 0x000F); /* 半透明off, TX off, GR on */
-
- /* マウスボタンが押されてるかキー入力があるあいだ */
- do {
- dmsstat(&x, &y, &l, &r);
- } while (l || r || clr_on());
-
- /* マウスボタンが押されるかキー入力があるまで */
- do {
- dmsstat(&x, &y, &l, &r);
- } while (!(l || r || clr_on() || del_on()));
-
- vsync();
- B_WPOKE(VIDEOR2, 0x1d2F); /* 半透明 TX & GR */
-
- if (del_on()) { /* v3.10e */
- g_off();
- }
- /* マウスボタンが押されてるかキー入力があるあいだ */
- do {
- dmsstat(&x, &y, &l, &r);
- } while (l || r || clr_on() || del_on());
-
- }
-
- /*
- グラフィック画面のみ一時消す
- */
- void
- g_off()
- {
- int x, y, l, r;
-
- vsync();
- B_WPOKE(VIDEOR2, 0x0020); /* 半透明off, TX on, GR off */
- do {
- dmsstat(&x, &y, &l, &r);
- } while (l || r || del_on());
- }
-
- void
- g_on()
- {
- vsync();
- B_WPOKE(VIDEOR2, 0x1d2f); /* 半透明 TX & GR */
- wait_mb_off();
- }
-
- /*
- グラフィック画面表示が ON (TRUE) か OFF (FALSE) かを返す
- */
- int
- g_disp()
- {
- if (B_WPEEK(VIDEOR2) & 0x001f) { /* 0x001f じゃなくて 1 でもいいのか */
- return TRUE;
- } else {
- return FALSE;
- }
- }
-
-
-
- void
- to_normal()
- {
- B_WPOKE(CRTCR20, 0x0315);
- B_WPOKE(CRTCR00, 0x5b);
- B_WPOKE(CRTCR01, 0x09);
- B_WPOKE(CRTCR02, 0x11);
- B_WPOKE(CRTCR03, 0x51);
- }
-
- void
- to_square()
- {
- B_WPOKE(CRTCR00, 0x89);
- B_WPOKE(CRTCR01, 0x0e);
- B_WPOKE(CRTCR02, 0x2c);
- B_WPOKE(CRTCR03, 0x6c);
- B_WPOKE(CRTCR20, 0x0316);
- }
-
-
- /*
- 垂直帰線期間を待つ
-
- void vsync(void);
- */
- asm("
- _vsync::
- suba.l a1,a1
- moveq.l #$81,d0
- trap #15
- @@: btst.b #4,$e88001
- beq @b
- @@: btst.b #4,$e88001
- bne @b
- tst.l d0
- bmi @f
- movea.l d0,a1
- moveq.l #$81,d0
- trap #15
- @@: rts
- ");
-
-
- /*
- 96桁(通常)モード、
- 64桁(画像)モードを
- セットする(切り替える)
-
- mode:セットするモード(GMODE)
- */
- int
- set_g_mode(int mode)
- {
- mouse(2);
- switch (mode) {
- case 0:
- if (GMODE) {
- vsync();
- B_WPOKE(VIDEOR2, 0);
- C_WIDTH(1);
- }
- break;
- case 1:
- case 2:
- if (!GMODE) {
- vsync();
- B_WPOKE(VIDEOR2, 0);
- C_WIDTH(5);
- noSetIbitFlag = TRUE;
- }
- vsync();
- if (mode == 1)
- to_normal();
- else
- to_square();
- break;
- default:
- return -1;
- }
- GMODE = mode;
- initPalet();
- setWidth();
-
- return 0;
- }
-